using FubuMVC.Core.Results;

namespace FubuMVC.Core.Behaviors
{
    public class render_the_view : IActionBehavior
    {
        private readonly string _viewToRender;
        private readonly ICurrentResult _currentResult;

        public render_the_view(string viewToRender, ICurrentResult currentResult)
        {
            _viewToRender = viewToRender;
            _currentResult = currentResult;
        }

        public IActionBehavior InsideBehavior { get; set; }
        public void Invoke()
        {
            _currentResult.OverrideIfNotAlreadyOverriden(new RenderViewResult(_viewToRender));

            InsideBehavior.Invoke();
        }
    }
}